#include<iostream>
#include<vector>
#include<unordered_map>

class Solution {
public:
    int majorityElement(std::vector<int>& nums) {
        int count = 0;
        std::unordered_map<int, int> map;
        int majority;

        for (size_t i = 0; i < nums.size(); i++) {
            map[nums[i]]++;
            if (map[nums[i]] > count) {
                count = map[nums[i]];
                majority = nums[i];
            }
        }
        return majority;
        
    }
};